package com.mybatis;

import java.io.Reader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.PageRow;
import com.mod.LoanConsultCertificateDo;

public class BaseMybaties{
	private static SqlSessionFactory sqlSessionFactory;
    private static Reader reader; 
    
    
    
    static{
        try{
            reader    = Resources.getResourceAsReader("mybatis-config.xml");
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
	

    public static void main(String[] args){
    	SqlSession session = sqlSessionFactory.openSession();
        try {
        	Map<String,Object> mapper = new HashMap<String,Object>();
        	mapper.put("name", "devangent");
        	mapper.put("page", new PageRow());
	        List<LoanConsultCertificateDo> lccDos = session.selectList("com.dao.ILoanConsultCertificateDao.selectLoanConsultCertificate", mapper);
	        System.out.println(lccDos.size());
	        System.out.println(lccDos);
        } finally {
        	session.close();
        }
    }
}
